package Client;

import javax.swing.*;
import java.awt.*;

public class AddFriendUI extends JFrame {

	User user;

	int WIDTH = 650, HEIGTH = 450;
	public Font Font;
	/**左上标签*/
	private JLabel title;
	private JLabel lSearch;
	/**搜索按钮*/
	public JButton bSearch;
	/**搜索框*/
	public JTextField inputSearchInfo;
	/**退出*/
	JButton bExit;
	/**最小化*/
	JButton bMin;

	AddFriendUI(User user) {
		this.user=user;
		setTitle(this.user.getUserId()+"添加好友");
		setSize(WIDTH, HEIGTH);
		setBackground(Color.gray);
		setLocationRelativeTo(null);
		setUndecorated(true);
		setResizable(false);
		setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		setAddFriendUI();
		setAddFriendActionListener(new AddFriendActionListener(this,this.user));
		setVisible(true);
	}

	public void setAddFriendUI() {//信息显示域
		setLayout(null);
		Font = new Font("楷体", java.awt.Font.BOLD, 18);

		title=new JLabel(this.user.getUserId()+"添加好友");
		add(title);
		title.setBounds(10,0,200,40);

		bMin = new JButton("—");
		bMin.setForeground(Color.BLACK);
		add(bMin);
		bMin.setBorder(null);
		bMin.setContentAreaFilled(false);
		bMin.setBounds(569, 0, 40, 30);

		bExit = new JButton("✕");
		bExit.setForeground(Color.BLACK);
		add(bExit);
		bExit.setBorder(null);
		bExit.setContentAreaFilled(false);//设置透明，显示出背景图片
		bExit.setBounds(609, 0, 40, 30);

		lSearch=new JLabel("QQ号码:");
		lSearch.setFont(Font);
		add(lSearch);
		lSearch.setBounds(80, 55, 80, 30);

		inputSearchInfo = new JTextField(400);
		inputSearchInfo.setFont(Font);
		inputSearchInfo.setBounds(170, 50, 400, 40);
		add(inputSearchInfo);

		bSearch = new JButton("查找");
		bSearch.setBounds(275,110, 100, 40);
		bSearch.setFont(Font);
		bSearch.setBackground(Color.CYAN);
		add(bSearch);

	}


	public void setAddFriendActionListener(AddFriendActionListener addFriendActionListener) {
		bMin.addActionListener(addFriendActionListener);
		bMin.addMouseListener(addFriendActionListener);
		bExit.addActionListener(addFriendActionListener);
		bExit.addMouseListener(addFriendActionListener);
		bSearch.addActionListener(addFriendActionListener);
		bSearch.addMouseListener(addFriendActionListener);
	}

}
